home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / polardrw / data.z / MainFrm.cpp < prev    next >
C/C++ Source or Header  |  1999-04-28  |  3KB  |  136 lines

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "DrawOcxTest.h"
  6.  
  7. #include "MainFrm.h"
  8.  
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CMainFrame
  17.  
  18. IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
  19.  
  20. BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
  21.     //{{AFX_MSG_MAP(CMainFrame)
  22.     ON_WM_CREATE()
  23.     ON_COMMAND(ID_VIEW_SHAPEBAR, OnViewShapebar)
  24.     ON_UPDATE_COMMAND_UI(ID_VIEW_SHAPEBAR, OnUpdateViewShapebar)
  25.     //}}AFX_MSG_MAP
  26. END_MESSAGE_MAP()
  27.  
  28. static UINT indicators[] =
  29. {
  30.     ID_SEPARATOR,           // status line indicator
  31.     ID_INDICATOR_CAPS,
  32.     ID_INDICATOR_NUM,
  33.     ID_INDICATOR_SCRL,
  34. };
  35.  
  36. /////////////////////////////////////////////////////////////////////////////
  37. // CMainFrame construction/destruction
  38.  
  39. CMainFrame::CMainFrame()
  40. {
  41.     // TODO: add member initialization code here
  42.     
  43. }
  44.  
  45. CMainFrame::~CMainFrame()
  46. {
  47. }
  48.  
  49. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  50. {
  51.     if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
  52.         return -1;
  53.     
  54.     if (!m_wndToolBar.Create(this) ||
  55.         !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  56.     {
  57.         TRACE0("Failed to create toolbar\n");
  58.         return -1;      // fail to create
  59.     }
  60.  
  61.     if (!m_wndShapeBar.Create(this) ||
  62.         !m_wndShapeBar.LoadToolBar(IDR_SHAPES))
  63.     {
  64.         TRACE0("Failed to create shape bar\n");
  65.         return -1;      // fail to create
  66.     }
  67.  
  68.     
  69.     if (!m_wndStatusBar.Create(this) ||
  70.         !m_wndStatusBar.SetIndicators(indicators,
  71.           sizeof(indicators)/sizeof(UINT)))
  72.     {
  73.         TRACE0("Failed to create status bar\n");
  74.         return -1;      // fail to create
  75.     }
  76.  
  77.     // TODO: Remove this if you don't want tool tips or a resizeable toolbar
  78.     m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
  79.         CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  80.  
  81.     // TODO: Remove this if you don't want tool tips or a resizeable toolbar
  82.     m_wndShapeBar.SetBarStyle(m_wndShapeBar.GetBarStyle() |
  83.         CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  84.  
  85.     
  86.     // TODO: Delete these three lines if you don't want the toolbar to
  87.     //  be dockable
  88.     m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  89.     m_wndShapeBar.EnableDocking(CBRS_ALIGN_LEFT | CBRS_ALIGN_RIGHT);
  90.     EnableDocking(CBRS_ALIGN_ANY);
  91.     DockControlBar(&m_wndToolBar);
  92.     DockControlBar(&m_wndShapeBar, AFX_IDW_DOCKBAR_LEFT);
  93.  
  94.     return 0;
  95. }
  96.  
  97. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  98. {
  99.     // TODO: Modify the Window class or styles here by modifying
  100.     //  the CREATESTRUCT cs
  101.  
  102.     return CMDIFrameWnd::PreCreateWindow(cs);
  103. }
  104.  
  105. /////////////////////////////////////////////////////////////////////////////
  106. // CMainFrame diagnostics
  107.  
  108. #ifdef _DEBUG
  109. void CMainFrame::AssertValid() const
  110. {
  111.     CMDIFrameWnd::AssertValid();
  112. }
  113.  
  114. void CMainFrame::Dump(CDumpContext& dc) const
  115. {
  116.     CMDIFrameWnd::Dump(dc);
  117. }
  118.  
  119. #endif //_DEBUG
  120.  
  121. /////////////////////////////////////////////////////////////////////////////
  122. // CMainFrame message handlers
  123.  
  124. void CMainFrame::OnViewShapebar() 
  125. {
  126.     BOOL fVisible = m_wndShapeBar.IsWindowVisible();
  127.     m_wndShapeBar.ShowWindow(!fVisible?SW_SHOW:SW_HIDE);
  128.     RecalcLayout();
  129. }
  130.  
  131. void CMainFrame::OnUpdateViewShapebar(CCmdUI* pCmdUI) 
  132. {
  133.     BOOL fVisible = m_wndShapeBar.IsWindowVisible();
  134.     pCmdUI->SetCheck(fVisible);
  135. }
  136.